//
//  HKDataSource.h
//  MVC
//
//  Created by 胡锦涛 on 2018/10/23.
//  Copyright © 2018 胡锦涛. All rights reserved.
/*
 //使用:
 static NSString * reuseId = @"reuseId";
 @interface ViewController ()
 @property (nonatomic, strong) UITableView * tableView;
 @property (nonatomic, strong) NSMutableArray * dataArray ;
 @property (nonatomic, strong) HKDataSource * dataSource ;
 @end
 
 @implementation ViewController
 -(NSMutableArray *)dataArray {
 if (!_dataArray) {
 _dataArray = @[].mutableCopy;
 }
 return _dataArray;
 }
 - (void)viewDidLoad {
 [super viewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.
 [self loadData];
 self.dataSource = [[HKDataSource alloc] initWithIdentifier:reuseId configureBlock:^(MVCTableViewCell *cell, Model *model, NSIndexPath *indexPath) {
 //赋值
 cell.model = model;
 }];
 [self.dataSource addDataArray:self.dataArray];
 self.view.backgroundColor = [UIColor whiteColor];
 [self.view addSubview:self.tableView];
 self.tableView.dataSource = self.dataSource;
 }
 - (void)loadData {
 NSArray * tempArray = @[@{@"name":@"Steven",@"imageUrl":@"http://cc",@"num":@"99"},
 @{@"name":@"Bob",@"imageUrl":@"http://cc",@"num":@"99"},
 @{@"name":@"Paul",@"imageUrl":@"http://cc",@"num":@"99"},
 @{@"name":@"Lucy",@"imageUrl":@"http://cc",@"num":@"99"}];
 for (int i = 0; i<tempArray.count; i++) {
 Model * model = [[Model alloc] init];
 [model setValuesForKeysWithDictionary:tempArray[i]];
 [self.dataArray addObject:model];
 }
 }
 -(UITableView *)tableView {
 if (!_tableView) {
 _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
 _tableView.tableFooterView = [UIView new];
 _tableView.backgroundColor = [UIColor whiteColor];
 [_tableView registerClass:[MVCTableViewCell class] forCellReuseIdentifier:reuseId];
 }
 return _tableView;
 }
 */

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

typedef void(^HKCellConfigure)(id cell , id model, NSIndexPath *indexPath);

@interface HKDataSource : NSObject<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray * dataArray ;

//自定义初始化方法
- (id)initWithIdentifier:(NSString *)identifier configureBlock:(HKCellConfigure)configure;

//CellIdentifier
@property (nonatomic, strong) IBInspectable NSString * cellIdentifier ;

//cellConfigure
@property (nonatomic, copy) HKCellConfigure cellConfigure ;

- (void)addDataArray:(NSArray*)array;

- (id)modelsAtIndexPath:(NSIndexPath*)indexPath;

@end

